package com.yuzhyn.hiops.common.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.yuzhyn.azylee.websdk.model.logs.WebAccessLog;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("sys_access_log")
public class SysAccessLog {
    private String id;
    private String ip;
    private LocalDateTime beginTime;
    private LocalDateTime endTime;
    private String uri;
    private String method;
    private Long elapsedTime;
    private String userId;
    private String step;
    private String threadName;
    private Long beginMaxMemory;
    private Long beginTotalMemory;
    private Long beginFreeMemory;
    private Long endMaxMemory;
    private Long endTotalMemory;
    private Long endFreeMemory;
    private Long probablyUseMemory;
    private String exception;

    public static SysAccessLog from(WebAccessLog webAccessLog) {
        SysAccessLog sysAccessLog = new SysAccessLog();
        sysAccessLog.setId(webAccessLog.getId());
        sysAccessLog.setIp(webAccessLog.getIp());
        sysAccessLog.setBeginTime(webAccessLog.getBeginTime());
        sysAccessLog.setEndTime(webAccessLog.getEndTime());
        sysAccessLog.setUri(webAccessLog.getUri());
        sysAccessLog.setMethod(webAccessLog.getMethod());
        sysAccessLog.setElapsedTime(webAccessLog.getElapsedTime());
        sysAccessLog.setUserId(webAccessLog.getUserId());
        sysAccessLog.setStep(webAccessLog.getStep());
        sysAccessLog.setThreadName(webAccessLog.getThreadName());
        sysAccessLog.setBeginMaxMemory(webAccessLog.getBeginMaxMemory());
        sysAccessLog.setBeginTotalMemory(webAccessLog.getBeginTotalMemory());
        sysAccessLog.setBeginFreeMemory(webAccessLog.getBeginFreeMemory());
        sysAccessLog.setEndMaxMemory(webAccessLog.getEndMaxMemory());
        sysAccessLog.setEndTotalMemory(webAccessLog.getEndTotalMemory());
        sysAccessLog.setEndFreeMemory(webAccessLog.getEndFreeMemory());
        sysAccessLog.setProbablyUseMemory(webAccessLog.getProbablyUseMemory());
        sysAccessLog.setException(webAccessLog.getException());
        return sysAccessLog;
    }
}
